// Generated using webpack-cli https://github.com/webpack/webpack-cli

const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');

const isProduction = process.env.NODE_ENV == 'production';


const config = {
    entry: {
        'main': './src/main.ts'
    },
    output: {
        filename: 'v5-drop.js',
        path: path.resolve(__dirname, 'dist'),
        library: 'v5Drop',
        libraryExport: 'default',
        libraryTarget: 'umd'
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: './index.html',
            chunks: ['vendor', 'main'],
            scriptLoading: 'blocking',
            inject: 'head'
        })
    ],
    module: {
        rules: [
            {
                test: /\.(ts|tsx)$/i,
                loader: 'ts-loader',
                exclude: ['/node_modules/'],
            }

            // Add your rules for custom modules here
            // Learn more about loaders from https://webpack.js.org/loaders/
        ],
    },
    resolve: {
        extensions: ['.ts', '.js'],
    },
    devServer: {
        port: 5000,
        host: 'localhost',
        hot: true
    }
};

module.exports = () => {
    if (isProduction) {
        config.mode = 'production';


    } else {
        config.mode = 'development';
    }
    return config;
};
